<template>
  <el-card style="margin-bottom: 20px">
    <template #header>
      <el-row :gutter="10" style="float: right">
        <el-button @click="toXML" type="primary">XML设置</el-button>
        <el-button @click="save">更 新</el-button>
      </el-row>
    </template>
  </el-card>
  <el-card header="报表基本信息">
    <el-form :model="form" label-position="left">
      <el-row :gutter="20">
        <el-col :xs="24" :sm="24" :md="24" :lg="8" :xl="8">
          <el-form-item label="报表类型">
            <el-select
              v-model="form.configType"
              clearable
              placeholder="请选择："
            >
              <el-option
                v-for="item in configData.configTypeList"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :xs="24" :sm="24" :md="24" :lg="8" :xl="8">
          <el-form-item label="名称">
            <el-input v-model="form.name" />
          </el-form-item>
        </el-col>
        <el-col :xs="24" :sm="24" :md="24" :lg="8" :xl="8">
          <el-form-item label="模块Id">
            <el-input v-model="form.appKey" />
          </el-form-item>
        </el-col>
        <el-col :xs="24" :sm="24" :md="24" :lg="8" :xl="8">
          <el-form-item label="文件名">
            <el-input v-model="form.fileName" />
          </el-form-item>
        </el-col>
        <el-col :xs="24" :sm="24" :md="24" :lg="8" :xl="8">
          <el-form-item label="显示模式">
            <el-select
              v-model="form.importPattern"
              clearable
              placeholder="请选择："
            >
              <el-option
                v-for="item in configData.importPatternList"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="备注">
            <el-input v-model="form.remark" type="textarea" />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </el-card>
</template>
<script setup>
import { ref, defineModel, onMounted } from "vue";
import API from "@/api/model/report.js";
import { ElNotification } from "element-plus";
import { useRoute, useRouter } from "vue-router";
import ErCanvas from "@/components/tsER/index";
const emit = defineEmits(["update", "init"]);
const route = useRoute();
const router = useRouter();
const props = defineProps({
  configData: { type: Array, default: ()=>[] },
});
const form = defineModel("formData");
const toXML = () => {
  router.push({
    path: "/reportXmlSetting",
    query: { fileName: route.query.fileName },
  });
};
const save = async () => {
  let param = {
    bean: form.value,
  };
  let res = API.updateBaseData.post(param);
  if (res.code == 200) {
    ElNotification.success({
      title: "",
      message: "操作成功！",
      duration: 2000,
    });
    emit("update");
    emit("init");
  }
};
</script>